package com.mgy.db;

/**
 * 表路由配置
 *
 * @author mgy
 * @date 2019.09.03
 */
public class TableRouter implements Comparable<String> {

    /**
     * 数据源默认前缀
     */
    public static final String DEFAULT_DS_PREFIX = "ds_";

    /**
     * 实际表默认分隔符
     */
    public static final String[] DEFAULT_TABLE_SEPARATOR = {"_", ""};
    /**
     * 逻辑表名
     */
    private String logicTable;
    /**
     * 分库号
     */
    private Integer dbNo;
    /**
     * 分表号
     */
    private Integer tableNo;
    /**
     * 数据源默认前缀
     */
    private String dsPrefix;
    /**
     * 实际表分隔符
     */
    private String tableSeparator;

    public String getLogicTable() {
        return logicTable;
    }

    public void setLogicTable(String logicTable) {
        this.logicTable = logicTable;
    }

    public Integer getDbNo() {
        return dbNo;
    }

    public void setDbNo(Integer dbNo) {
        this.dbNo = dbNo;
    }

    public Integer getTableNo() {
        return tableNo;
    }

    public void setTableNo(Integer tableNo) {
        this.tableNo = tableNo;
    }

    public String getDsPrefix() {
        return dsPrefix == null ? DEFAULT_DS_PREFIX : dsPrefix;
    }

    public void setDsPrefix(String dsPrefix) {
        this.dsPrefix = dsPrefix;
    }

    public String getTableSeparator() {
        return tableSeparator;
    }

    public void setTableSeparator(String tableSeparator) {
        this.tableSeparator = tableSeparator;
    }

    @Override
    public int hashCode() {
        return (logicTable == null ? "" : logicTable).hashCode();
    }


    @Override
    public boolean equals(Object obj) {
        if (obj instanceof String) {
            String str = (String) obj;
            if (logicTable != null && logicTable.equals(str)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public int compareTo(String o) {
        return 0;
    }
}
